﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Simhopp.GUI;
using Simhopp.Model;

namespace Simhopp.Presenter
{
    class PresenterOngoingCompetition
    {
        public InterfaceDiverModel _modelDiver { get; set; }
        public InterfaceCompetitionModel _modelCompetition { get; set; }
        public InterfaceListenerModel _modelListener { get; set; }
        public InterfaceOngoingCompetitionView _view { get; set; }

        public PresenterOngoingCompetition(InterfaceOngoingCompetitionView view, InterfaceCompetitionModel modelCompetition, InterfaceListenerModel modelListener)
        {
            this._view = view;
            this._modelCompetition = modelCompetition;
            this._modelDiver = null;
            this._modelListener = modelListener;
            this._view.EventGetDiverList += _view_EventGetDiverList;
            this._view.EventGetDiveByDiveNumber += _view_EventGetDiveByDiveNumber;
            this._view.EventMoveDiverToBack += _view_EventMoveDiverToBack;
            this._view.EventStart += _view_EventStart;
            this._view.EventStop += _view_EventStop;
            this._view.EventAddScoreAndJudgeIDToJudgeScoreDict += _view_EventAddScoreAndJudgeIDToJudgeScoreDict;
            this._view.EventGetRound += _view_EventGetRound;
            this._view.EventGetJudgeScoreForDive += _view_EventGetJudgeScoreForDive;
            this._view.EventCalculateTotalScoreForDive += _view_EventCalculateTotalScoreForDive;
            this._view.EventCalculateTotalPointsForDiver += _view_EventCalculateTotalPointsForDiver;
 
        }

        void _view_EventCalculateTotalPointsForDiver()
        {
            this._modelDiver.CalculateTotalPoints();
        }

        void _view_EventCalculateTotalScoreForDive(int DiveNr)
        {
            this._modelDiver.CalculateTotalScoreForDive(DiveNr);
        }

        Dictionary<int, double> _view_EventGetJudgeScoreForDive(int DiveNr)
        {
            return this._modelDiver.GetJudgeScoreForDive(DiveNr);
        }
        int _view_EventGetRound()
        {
            return this._modelCompetition.Round;
        }

        void _view_EventAddScoreAndJudgeIDToJudgeScoreDict(int JudgeID, int DiveNr, double Score)
        {
            this._modelDiver.AddScoreAndJudgeIDToJudgeScoreDict(JudgeID, DiveNr, Score);
        }

        void _view_EventStop()
        {
            this._modelListener.Stop();
        }

        void _view_EventStart()
        {
            this._modelListener.Start();
        }


        void _view_EventMoveDiverToBack(Diver diver)
        {
            this._modelCompetition.MoveDiverToBack(diver);
        }

        Dive _view_EventGetDiveByDiveNumber(int number)
        {
            return this._modelDiver.GetDiveByNumber(number);
        }

        List<Diver> _view_EventGetDiverList()
        {
            return this._modelCompetition.DiverList;
        }
    }
}
